const path = require("path");
const resolve = dir => path.join(__dirname, dir);
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
    transpileDependencies: true,
    publicPath: '/',
    productionSourceMap: process.env.NODE_ENV === 'production' ? false : true,
    assetsDir: 'static',
    devServer: {
        allowedHosts: 'all',
        port: 8180,
        client: {
            overlay: false // 编译错误时，取消全屏覆盖
        },
        proxy: {

        }
    },
    // css: {
    //     loaderOptions: {
    //         less: {
    //             lessOptions: {
    //                 javascriptEnabled: true
    //             }
    //         }
    //     }
    // },
    configureWebpack: (config) => {
        if (process.env.NODE_ENV === 'production') {
            // config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
            // config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = [
            //     'console.log',
            //     'console.info',
            //     'console.debug', // 可移除指定的 console 方法
            // ]
        }
    },
    chainWebpack: config => {
        config.resolve.alias
            .set("@", resolve("src"))

        // config.plugin('webpack-bundle-analyzer')
        //     .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)

        const oneOfsMap = config.module.rule("less").oneOfs.store;
        oneOfsMap.forEach(item => {
            item.use('sass-resources-loader')
                .loader('sass-resources-loader')
                .options({
                    resources: [
                        resolve("src/styles/base.less"),
                    ]
                })
                .end()
        })
        config.plugins.delete('prefetch');
    }
})
